package com.zyk.leetcode;

import java.util.Arrays;

/**
 * @author zhangsan
 * @date 2021/4/18 11:43
 */
public class C164 {

    // https://leetcode-cn.com/problems/maximum-gap/
    public static int maximumGap(int[] nums) {
        if(nums.length < 2) return 0;
        Arrays.sort(nums);
        int ans = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length - 1; i++) {
            ans = Math.max(ans, nums[i + 1] - nums[i]);
        }
        return ans;
    }


    // for test
    public static void main(String[] args) {
        int[] nums = {3,6,9,1};
        System.out.println(maximumGap(nums));
    }

}
